package com.java46.admin.manager.dao;

import com.java46.admin.base.util.HibernateUtils;
import com.java46.admin.manager.entity.ManagerEntity;
import org.hibernate.Session;
import org.hibernate.query.Query;

public class ManagerDao {
    /**
     * 管理员登录
     * @param managerName 管理员账户
     * @param managerPassword 管理员密码
     * @return 一个集合判断是否有该用户
     */
    public ManagerEntity query_Manager(String managerName, String managerPassword){
        ManagerEntity managerEntity = null;
        Session session = HibernateUtils.getSession();
        Query query = HibernateUtils.getQuery("from com.java46.admin.manager.entity.ManagerEntity me where me.managerName=?1 and me.managerPassword=?2");
        query.setParameter(1,managerName);
        query.setParameter(2,managerPassword);
        if(query.list().size()!=0){
            managerEntity = (ManagerEntity)query.list().get(0);
        }
        session.close();
        return managerEntity;
    }
}
